Skip to content

fix: preserve explicit runtime retriever overrides - #12167

Closed
vinkiYu wants to merge 3 commits into
deepset-ai:mainfrom
vinkiYu:fix/runtime-retriever-overrides
Closed

fix: preserve explicit runtime retriever overrides#12167
vinkiYu wants to merge 3 commits into
deepset-ai:mainfrom
vinkiYu:fix/runtime-retriever-overrides

Conversation

@vinkiYu

@vinkiYu vinkiYu commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve an explicitly provided empty ilters={} in FilterRetriever, including synchronous, asynchronous, and Pipeline execution.
  • Validate runtime window_size values in SentenceWindowRetriever consistently across constructor, sync, and async paths.
  • Add regression tests and release notes.

Tests

  • python -m py_compile passed for all changed Python files.
  • Hatch/pytest were not run in the available environment: Hatch is not installed and the available Python is 3.8.6, below Haystack's supported range.

@vinkiYu
vinkiYu requested a review from a team as a code owner July 27, 2026 14:59
@vinkiYu
vinkiYu requested review from julian-risch and removed request for a team July 27, 2026 14:59
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@vinkiYu is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Jul 27, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@vinkiYu
vinkiYu force-pushed the fix/runtime-retriever-overrides branch from c8fbbd7 to f16dd9a Compare July 28, 2026 09:08
@github-actions github-actions Bot added the type:documentation Improvements on the docs label Jul 28, 2026
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/retrievers
  filter_retriever.py
  sentence_window_retriever.py
Project Total  

This report was generated by python-coverage-comment-action

@julian-risch

Copy link
Copy Markdown
Member

@vinkiYu Thank you for opening this PR! I understand that there should be a simple way to reset filters in the run method to overwrite whatever filters were set in init. However, {} is not a valid filter dict in our filter spec because it has no operator/conditions key. Currently, a pipeline that builds its filter dict conditionally (ConditionalRouter, a Jinja template, an LLM-produced dict) and yields {} for the no-filter case falls back to the init filters. After this PR the same pipeline would return the entire document store, which is a breaking change with big impact.

As a workaround, you can use {"field": "id", "operator": "!=", "value": "__nope__"}, which works for all our different document stores. An alternative is to pass filters at runtime only and build the input dict conditionally. That way, the filters key is only set when needed:

inputs = {"filters": user_filters} if user_filters else {}
pipeline.run(data={"retriever": inputs})

We could also think about implementing a Haystack NO_FILTERS object. However, if we introduce it, we should ensure that it works with all retrievers in haystack-core-integrations too.

The existing workaround and the breaking change are the main reasons for me to close this PR.


Regarding the other change (window_size=0):
Could you please open a separate pull request and:

  • Update run_async docstring according to your changes and mention window_size=0 is rejected
  • Use hatch run release-note to generate release notes (see also AGENTS.md).
  • Clean up the dead run(...) calls in the renamed init tests after the assert

Thank you so much! Looking forward to your PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants